# Quick start

## Setup environment

Before getting started, you will need to install [Node.js](https://nodejs.org/) >= 18.12.0, it is recommended to use the Node.js LTS version.

Check the current Node.js version with the following command:

```bash
node -v
```

If you do not have Node.js installed in current environment, or the installed version is too low, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install.

Here is an example of how to install via nvm:

```bash
# Install Node.js LTS
nvm install --lts
# Switch to Node.js LTS
nvm use --lts
```

## Creating an Rslib project

You can use the [`create-rslib`](https://www.npmjs.com/package/create-rslib) to create a new Rslib project. Run the following command:

import { PackageManagerTabs } from '@theme';

<PackageManagerTabs
  command={{
    npm: 'npm create rslib@latest',
    yarn: 'yarn create rslib',
    pnpm: 'pnpm create rslib@latest',
    bun: 'bun create rslib@latest',
  }}
/>

Then follow the prompts to complete the operation.

### Templates

`create-rslib` is a tool for quickly creating Rslib projects. When creating a project, you can choose from the following templates:

| Template                     | Description                  |
| ---------------------------- | ---------------------------- |
| Node.js dual ESM/CJS package | Node.js dual ESM/CJS package |
| Node.js pure ESM package     | Node.js pure ESM package     |
| React                        | React component library      |
| Vue                          | Vue component library        |

Each template supports both JavaScript and TypeScript, along with optional development tools, formatters, and linters.

### Development tools

`create-rslib` can help you set up some commonly used development tools, including [Rstest](https://rstest.rs/), [Vitest](https://vitest.dev/), [Storybook](https://storybook.js.org/). You can use the arrow keys and the space bar to make your selections. If you don't need these tools, you can simply press Enter to skip.

- Rstest and Vitest are available for all templates, it will be adapted based on the template's selection.
- Storybook is available for web targeted templates (React, Vue), it will be adapted based on the template's selection.

```text
◆  Select development tools (Use <space> to select, <enter> to continue)
│  ◻ Storybook
│  ◻ Rstest
│  ◻ Vitest
└
```

### Optional tools

`create-rslib` can help you set up some commonly used linter and formatter tools, including [Biome](https://biomejs.dev/), [ESLint](https://eslint.org/), and [prettier](https://prettier.io/). You can use the arrow keys and the space bar to make your selections. If you don't need these tools, you can simply press Enter to skip.

```text
◆  Select additional tools (Use <space> to select, <enter> to continue)
│  ◻ Add Biome for code linting and formatting
│  ◻ Add ESLint for code linting
│  ◻ Add Prettier for code formatting
└
```

:::tip
Biome provides similar linting and formatting features to ESLint and Prettier. If you select Biome, you typically won't need to choose ESLint or Prettier as well.
:::

### Current directory

If you need to create a project in the current directory, you can set the target folder to `.`:

```text
◆  Create Rslib Project
│
◇  Project name or path
│  .
│
◇  "." is not empty, please choose:
│  Continue and override files
```

### Quick creation

[create-rslib](https://www.npmjs.com/package/create-rslib) provides some CLI flags. By setting these CLI flags, you can skip the interactive selection steps and create the project with one command.

For example, to create a React + TypeScript + Storybook + Biome project in the `my-project` directory with one command:

```bash
npx create-rslib --dir my-project --template react-ts --tools storybook --tools biome

# Using abbreviations
npx create-rslib -d my-project -t react-ts --tools storybook --tools biome
```

All the CLI flags of `create-rslib`:

```text
Usage: create-rslib [options]

Options:

  -h, --help       display help for command
  -d, --dir        create project in specified directory
  -t, --template   specify the template to use
  --tools          select additional tools (biome, eslint, prettier)
  --override       override files in target directory
```

## Migrate from existing projects

To migrate from an existing project to Rslib, refer to the following guides:

- [Migrating from tsup](/guide/migration/tsup)
- [Migrating from Modern.js Module](/guide/migration/modernjs-module)

### Other projects

For other types of projects, you can manually install the [@rslib/core](https://www.npmjs.com/package/@rslib/core) package:

<PackageManagerTabs command="add @rslib/core -D" />

Then refer to the guide and documentation to enable the features you need:

- See [CLI](/guide/basic/cli) to learn about available CLI commands.
- See [Configure Rslib](/guide/basic/configure-rslib) to configure Rslib.
